package dao

import (
	"miao-server/global"
	"miao-server/structs/tables"
)

var DeviceDao = new(deviceDao)

type deviceDao struct {
}

func (d deviceDao) FindByUniqueCode(uniqueCode string) (m tables.Device, err error) {
	err = global.DB.Where(&tables.Device{UniqueValue: uniqueCode}).Find(&m).Error
	return
}

func (d deviceDao) FindAbnormalByUniqueCode(uniqueCode string) (m tables.DeviceAbnormal, err error) {
	err = global.DB.Where(&tables.DeviceAbnormal{UniqueForDB: uniqueCode}).First(&m).Error
	return
}

func (d deviceDao) SaveLogLoad(m tables.LogLoad) (err error) {
	err = global.DB.Save(&m).Error
	return
}
